﻿using EPiAbstractions.Community.Blog;
using EPiServer.Community.Blog;
using Moq;
using StructureMap.AutoMocking;
using Xunit;

namespace JoelAbrahamsson.MetaWeblog.Tests
{
    public class GetBlogTests
    {
        [Fact]
        public void GivenID_GetBlog_ReturnsBlogFromHandler()
        {
            int id = 1;
            Blog expectedBlog = new Mock<Blog>().Object;
            MoqAutoMocker<MetaWeblogHandler> metaWebLogHandlerAutoMocker = new MoqAutoMocker<MetaWeblogHandler>();
            Mock.Get(metaWebLogHandlerAutoMocker.Get<IBlogHandlerFacade>()).Setup(handler => handler.GetBlog(id)).Returns(expectedBlog);

            Blog returnedBlog = metaWebLogHandlerAutoMocker.ClassUnderTest.GetBlog(id.ToString());

            Assert.NotNull(returnedBlog);
            Assert.Equal<Blog>(expectedBlog, returnedBlog);
        }
    }
}
